package com.sy.controller.report;

import com.sy.bean.pucharse.excel.PurchaseExcel;
import com.sy.bean.report.ChoosePurchaseReport;
import com.sy.bean.report.PurchaseReport;
import com.sy.bean.report.PurchaseReportExcel;
import com.sy.common.bean.PageBean;
import com.sy.common.bean.ResultBean;
import com.sy.common.controller.BaseController;
import com.sy.common.utils.BeanOfMap;
import com.sy.service.report.PurchaseReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "报表")
@RestController
@RequestMapping("/api/report")
public class PurchaseReportController extends BaseController {
    @Autowired
    PurchaseReportService purchaseReportService;

    @ApiOperation("采购报表")
    @PostMapping("/report/purchase")
    public ResultBean<PageBean<PurchaseReport>> query(@RequestBody ChoosePurchaseReport report) {
        List<Map> bean = purchaseReportService.queryList(BeanOfMap.bom(report));
        return success("采购报表", bean);
    }

    @ApiOperation("查询供应商名称")
    @GetMapping("/supplierName")
    public ResultBean querySupplierName(int eid) {
        List list = purchaseReportService.querySupplierName(eid);
        return success("查询供应商名称", list);
    }

    @ApiOperation("查询仓库名称")
    @GetMapping("/warehouse")
    public ResultBean queryWarehouse(int eid) {
        List list = purchaseReportService.queryWarehouse(eid);
        return success("查询仓库名称", list);
    }

    @ApiOperation("导出采购报表列表")
    @PostMapping("/exportPurchaseReport")
    public ResultBean<PurchaseReportExcel> exportPR(@RequestBody Map map){
        String url = purchaseReportService.exportPurchaseReport(map);
        return success("导出采购报表列表",url);
    }
}
